package DataStructure.graph;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Traffic_Project_Test2 {
    public static void main(String[] args) throws Exception{
        //构建一个缓冲读取流
        BufferedReader br = new BufferedReader(new InputStreamReader(Traffic_Project_Test2.class.getClassLoader().getResourceAsStream("traffic_project.txt")));
        //读取第一行数据
        int totalNumber =Integer.parseInt(br.readLine());
        //构建一个图对象
        Graph G = new Graph(totalNumber);
        //读取第二行数据
        int roadNumber = Integer.parseInt(br.readLine());
        //循环读取7次，读取已经构建好的道路
        for (int i = 1; i <= roadNumber ; i++) {
            String road = br.readLine();
            String[] str = road.split(" ");
            int v = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            G.addEdge(v,w);
        }
        //构建一个深度优先搜索对象，起点为9
        DepthFirstSearch search = new DepthFirstSearch(G, 9);
        //调用marked方法，判断8和10是否与9想通
        boolean marked1 = search.marked(8);
        boolean marked2 = search.marked(10);
        System.out.println("8顶点与9顶点是否想通:"+marked1);
        System.out.println("10顶点与9顶点是否想通:"+marked2);
    }
}
